import { AnimationClip } from 'cc'
import { State } from '../base/State'
import { StateMachine } from '../base/StateMachine'
import { SubStateMachine } from '../base/SubStateMachine'
import { ENTITY_STATE_ENUM, SPIKES_COUNT_MAP_NUMBER_ENUM, SPIKES_SUB_STATE_ENUM } from '../enums'
import { SPIKES_ANIMATION_PATH } from '../utils/constants'
/** 子状态机 四个地刺 */
export default class SpikesFourSubStateMachine extends SubStateMachine {
  constructor(fsm: StateMachine) {
    super(fsm)
    // 保存四个地刺的6个数量的状态机
    this.stateMachines.set(SPIKES_SUB_STATE_ENUM.ZERO, new State(fsm, SPIKES_ANIMATION_PATH.spikesfourZero))
    this.stateMachines.set(SPIKES_SUB_STATE_ENUM.ONE, new State(fsm, SPIKES_ANIMATION_PATH.spikesfourOne))
    this.stateMachines.set(SPIKES_SUB_STATE_ENUM.TWO, new State(fsm, SPIKES_ANIMATION_PATH.spikesfourTwo))
    this.stateMachines.set(SPIKES_SUB_STATE_ENUM.THREE, new State(fsm, SPIKES_ANIMATION_PATH.spikesfourThree))
    this.stateMachines.set(SPIKES_SUB_STATE_ENUM.FOUR, new State(fsm, SPIKES_ANIMATION_PATH.spikesfourFour))
    this.stateMachines.set(SPIKES_SUB_STATE_ENUM.FIVE, new State(fsm, SPIKES_ANIMATION_PATH.spikesfourFive))
  }

  run() {
    const value = this.fsm.getParams(ENTITY_STATE_ENUM.SPIKES_CUR_COUNT) // 获取存储当前地刺数量
    this.currentState = this.stateMachines.get(SPIKES_COUNT_MAP_NUMBER_ENUM[value as number]) // 根据数量取出对应的状态机
  }
}
